<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Java Web Socket</title>
</head>
<body>
<script>
var ws = new WebSocket("ws://chatroom.iorichina.cc:8080/wsServlet");
ws.onopen = function(){};
ws.onmessage = function(message){
	document.getElementById("chatlog").textContent += message.data + "\n";
};

function postToServer() {
	ws.send(document.getElementById("msg").value);
	document.getElementById("msg").value = "";
}

function closeConnect() {
	ws.close();
}
</script>

<div>
	<textarea rows="10" cols="100" id="chatlog" readonly="readonly"></textarea>
</div>
<div>
	<input id="msg" type="text" onkeydown="if(event.keyCode == 13){document.getElementById('send').click();}" />
	<button type="submit" onclick="postToServer()" id="send">Send</button>
	<button type="submit" onclick="closeConnect()">Close</button>
</div>
</body>
</html>